import { useState } from 'react';
import styles from './menu.module.scss';

const Menu = ({ onMenuChange, currentContent }) => {
    const [activeKey, setActiveKey] = useState(currentContent);

    const menuItems = [
        {
            key: 'home',
            label: '首页',
            iconPath: '/images/homeTab.png',
            activeIconPath: '/images/homeTabActive.png'
        },
        {
            key: 'system',
            label: '系统维护',
            iconPath: '/images/systemTab.png',
            activeIconPath: '/images/systemTabActive.png'
        },
        {
            key: 'stats',
            label: '数据统计',
            iconPath: '/images/dataTab.png',
            activeIconPath: '/images/dataTabActive.png'
        },
        {
            key: 'user',
            label: '用户管理',
            iconPath: '/images/userTab.png',
            activeIconPath: '/images/userTabActive.png'
        },
        {
            key: 'goods',
            label: '物品管理',
            iconPath: '/images/goodsTab.png',
            activeIconPath: '/images/goodsTabActive.png'
        },
        {
            key: 'interaction',
            label: '互动展示',
            iconPath: '/images/interactionTab.png',
            activeIconPath: '/images/interactionTabActive.png'
        }
    ];

    const handleMenuClick = (key) => {
        setActiveKey(key);
        onMenuChange(key);
    };

    return (
        <div className={styles.menu}>
            {menuItems.map(item => (
                <div
                    key={item.key}
                    className={styles.menu__item}
                    onClick={() => handleMenuClick(item.key)}
                >
                    <img className={styles.menu__itemIcon} src={activeKey === item.key ? item.activeIconPath : item.iconPath} alt={item.label} />
                    <span className={`${styles.menu__itemLabel} ${activeKey === item.key ? styles['menu__itemLabel--active'] : ''}`}>{item.label}</span>
                </div>
            ))}
        </div>
    );
};

export default Menu; 